package com.ry.day1129;
import java.util.*;


public class LC169 {

    static class Solution {
        /**
         * @param n: the number of disks
         * @return: the order of moves
         */
        public List<String> towerOfHanoi(int n) {
            List<String> ans = new ArrayList<>();
            hnt(n,'A','B','C',ans);
            return ans;
        }

        public void move(char a,char c,List<String> ans){
            ans.add("from "+ a+" to "+c);
        }

        public void hnt(int n,char a,char b,char c,List<String> ans){
            if(n==1) {
                move(a,c,ans);
            }else{
                hnt(n-1,a,c,b,ans);
                move(a,c,ans);
                hnt(n-1,b,a,c,ans);
            }
        }
    }


    public static void main(String[] args) {
        Solution obj = new Solution();
        System.out.println(obj.towerOfHanoi(2));
        System.out.println(obj.towerOfHanoi(3));
    }
}
